﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using RayDen.RayEngine;

namespace Eucalyptus
{
    public partial class AppForm : Form
    {
        public AppController Controller;
        public AppForm()
        {
            InitializeComponent();
            Controller = new AppController();
            
        }

        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            Controller.InitLog(this.txtLog);
            this.propertyGrid1.SelectedObject = GlobalConfiguration.Instance;
        }

        private void btnOpenFrame_Click(object sender, EventArgs e)
        {
            if (openFileDialog1.ShowDialog() == DialogResult.OK)
            {
                this.Controller.LoadFrame(this.openFileDialog1.FileName);
                txtPath.Text = openFileDialog1.FileName;
            }
            this.Text += " " + Controller.Frame.FrameName;
        }

        private async void btnStartRenderer_Click(object sender, EventArgs e)
        {
            await this.Controller.StartRenderer();
        }

        private async void btnStopRenderer_Click(object sender, EventArgs e)
        {
            await this.Controller.StopRenderer();
        }

        private void globalToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.propertyGrid1.SelectedObject = GlobalConfiguration.Instance;

        }

        private void engineToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.propertyGrid1.SelectedObject = this.Controller.re.engine;
        }
    }
}
